<?php
/*
	
*/
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();

if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['name'])){
		$params['name']=trim($_RQ['name']);
		$return['params']['name']=$params['name'];
	}
	$fields=array('awardinfo','awardLevel','award','createtime','awardstatus','ausername','address','aphone','id');
	$parameter=array('params'=>$params,'limit'=>array($pindex,$psize),'fields'=>$fields,'orderby'=>'id desc');
	$list=$this->get_list('award',$parameter,$total);
	if($list){
		foreach($list as &$item){
			
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array (
		  'type' => 'list',
		  'tabs' =>
		  array (
		    0 => array('op' => 'list','title' => '获奖名单'),	
			1 => array('op' => 'list2','title' => '玩家列表'),
			2 => array('op' => 'list3','title' => '活动黑名单')
		  ),
		  'list' => array('data' => 'list','edit'=>false,
		    'list' =>array(0 => array ('type' => 'string','name' => 'awardinfo','title' => '中奖玩家',
),
		      1 => 
		      array (
		        'name' => 'awardLevel',
		        'type' => 'string',
		        'title' => '奖项等级',
		      ),
		      2 => 
		      array (
		        'name' => 'award',
		        'type' => 'string',
		        'title' => '奖品',
		      ),
		      3 => 
		      array (
		        'type' => 'radio',
		        'name' => 'status',
		        'title' => '卡券状态',
				'options' => 'status_xuanxiang'
		      ),
			  4 => 
		      array (
		        'name' => 'ausername',
		        'type' => 'string',
		        'title' => '姓名',
		      ),
			   5 => 
			   array (
		        'name' => 'aphone',
		        'type' => 'string',
		        'title' => '联系电话',
		      ),   
			   6 => 
			   array (
		        'name' => 'address',
		        'type' => 'string',
		        'title' => '地址',
		      ),   
		    ),
		  ),
		  'search' => 
		  array(
		  0 =>
		  array (
		        'name' => 'awardinfo',
				'width'=>'15',
		        'type' => 'string',
		        'title' => '玩家昵称',
		  ),
		  ),
		);
    $return['status_xuanxiang']=array (
      1 => '未核销',
      2 => '已核销',
     );
	exi($return);
}
if($_RQ['op']=='list2'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'shielding'=>!2);
	if(!empty($_RQ['name'])){
		$params['name']=trim($_RQ['name']);
		$return['params']['name']=$params['name'];
	}
	$fields=array('headImg','name','awardinfo','ausername','tel','address','createtime','id');
	$parameter=array('params'=>$params,'limit'=>array($pindex,$psize),'fields'=>$fields,'orderby'=>'id desc');
	$list=$this->get_list('fans',$parameter,$total);
	//exi($list,'error');
	if($list){
		foreach($list as &$item){
			
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array (
		  'type' => 'list',
		  'tabs' =>
		  array (
		    0 => array('op' => 'list','title' => '获奖名单'),	
			1 => array('op' => 'list2','title' => '玩家列表'),
			2 => array('op' => 'list3','title' => '活动黑名单')
		  ),
		  'list' => array('data' => 'list','edit'=>false,
		    'list' =>array(
			0 => 
			array ('type' => 'image','name' => 'headImg','title' => '玩家头像',
),
		      1 => 
		      array (
		        'name' => 'name',
		        'type' => 'string',
		        'title' => '玩家昵称',
		      ),
		      2 => 
		      array (
		        'name' => 'awardinfo',
		        'type' => 'string',
		        'title' => '获得奖项',
		      ),
		      3 => 
		      array (
		        'type' => 'string',
		        'name' => 'ausername',
		        'title' => '姓名',
		      ),
			  4 => 
		      array (
		        'name' => 'tel',
		        'type' => 'string',
		        'title' => '联系电话',
		      ),
			   5 => 
			   array (
		        'name' => 'address',
		        'type' => 'string',
		        'title' => '地址',
		      ),
),'action'=>array(
			array('type'=>'post','op'=>'shielding','title'=>'移入黑名单','message'=>'确认移入黑名单吗！'),
			
			
		)			  
		
		  ),
		  'search' => 
		  array(
		  0 =>
		  array (
		        'name' => 'name',
		        'type' => 'string',
		        'title' => '玩家昵称',
		  ),
		  ),
		);
	exi($return);
}
if($_RQ['op']=='list3'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'shielding'=>2);
	if(!empty($_RQ['name'])){
		$params['name']=trim($_RQ['name']);
		$return['params']['name']=$params['name'];
	}
	$fields=array('headImg','name','awardinfo','ausername','tel','address','createtime','id');
	$parameter=array('params'=>$params,'limit'=>array($pindex,$psize),'fields'=>$fields,'orderby'=>'id desc');
	$list=$this->get_list('fans',$parameter,$total);
	if($list){
		foreach($list as &$item){
			
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array (
		  'type' => 'list',
		  'tabs' =>
		  array (
		    0 => array('op' => 'list','title' => '获奖名单'),	
			1 => array('op' => 'list2','title' => '玩家列表'),
			2 => array('op' => 'list3','title' => '活动黑名单')
		  ),
		  'list'=> array('data' => 'list','edit'=>false,'list' =>array(
			  0 => array('type' => 'image','name' => 'headImg','title' => '玩家头像',),
		      1 => array('name' => 'name','type' => 'string','title' => '玩家昵称',),
		      2 => array('name' => 'awardinfo','type' => 'string','title' => '获得奖项',),
		      3 => array('type' => 'string','name' => 'ausername', 'title' => '姓名',),
			  4 => array('name' => 'tel','type' => 'string','title' => '联系电话',),
			  5 => array('name' => 'address','type' => 'string','title' => '地址',),      
		    ),
			'action'=>array(
			array('type'=>'post','op'=>'unshielding','title'=>'移出黑名单','message'=>'确认移出黑名单吗！'),
		  ),
		  ),
		  'search' => array(0 =>array ('name' => 'name','type' => 'string','title' => '玩家昵称',),),);
	exi($return);
     }
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		$this->delete('award',array('id'=>$id));
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				$this->delete('award',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
	
}
if($_RQ['op']=='shielding'){
	
	$id=intval($_RQ['id']);
	
	if($id){

		$this->update('fans',array('shielding'=>'2'),array('id'=>$id));
	}
	$shielding=trim($_RQ['shielding'],';');
	if($shielding){
		$shielding=explode(';',$shielding);
		foreach($shielding as $id){
			$id=intval($id);
			if($id){
				$this->update('fans',array('shielding'=>'2'),array('id'=>$id));
			}
		}
	}
	exi('成功移入黑名单！');
	
}
if($_RQ['op']=='unshielding'){
	
	$id=intval($_RQ['id']);
	
	if($id){

		$this->update('fans',array('shielding'=>'1'),array('id'=>$id));
	}
	$shielding=trim($_RQ['shielding'],';');
	if($shielding){
		$shielding=explode(';',$shielding);
		foreach($shielding as $id){
			$id=intval($id);
			if($id){
				$this->update('fans',array('shielding'=>'1'),array('id'=>$id));
			}
		}
	}
	exi('成功移出黑名单！');
	
}
